package com.groupa.project1.swing;

import com.groupa.project1.database.PhotoClass;
import com.groupa.project1.chat.InstantMessageClass;
import com.groupa.project1.chat.ListenerClass;
import com.groupa.project1.chat.ToolsClass;
import com.groupa.project1.chat.interfaces.InstantMessage;
import com.groupa.project1.database.DBActionClass;
import com.groupa.project1.database.DBManagerClass;
import com.groupa.project1.database.PhotoClass;
import com.groupa.project1.database.interfaces.DBActionResult;
import com.groupa.project1.database.interfaces.DBManager;
import com.sun.media.jai.widget.DisplayJAI;
import java.awt.Dimension;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.swing.BoxLayout;
import javax.swing.JScrollPane;


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * photographersMenu.java
 *
 * Created on 15-feb-2012, 20:36:24
 */

public class photographersMenu extends javax.swing.JFrame {
    //private photographersMenu ph = new photographersMenu();
    PhotoClass PhotoSelected2,PhotoSelected3,PhotoSelected4,PhotoSelected5,PhotoSelected6,PhotoSelected7;
    PhotoClass PhotoSend;
    boolean Panel2Activated,Panel3Activated,Panel4Activated,Panel5Activated,Panel6Activated,Panel7Activated;
    private static String emailLogin;
    Logger log;
    InstantMessage instance;
    Properties Prop;
    private static photographersMenu PM;
    int num_photo=1;
    /** Creates new form photographersMenu */
    private photographersMenu() {
        initComponents();
        jLabel4.setVisible(false);
        emailLogin = login.getLogin();
        jLabel2.setText(emailLogin);
        Prop = InstantMessageClass.getPropertiesStatic();
        instance = InstantMessageClass.GetInstance();
        log = InstantMessageClass.getLog();
        showPhotos();
    }
    public static photographersMenu getPhotographersMenu(){
        if(PM == null){
            PM = new photographersMenu();
        }
        
        return PM;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jCheckBox2 = new javax.swing.JCheckBox();
        jPanel3 = new javax.swing.JPanel();
        jCheckBox4 = new javax.swing.JCheckBox();
        jPanel4 = new javax.swing.JPanel();
        jCheckBox3 = new javax.swing.JCheckBox();
        jPanel5 = new javax.swing.JPanel();
        jCheckBox5 = new javax.swing.JCheckBox();
        jPanel7 = new javax.swing.JPanel();
        jCheckBox6 = new javax.swing.JCheckBox();
        jPanel6 = new javax.swing.JPanel();
        jCheckBox7 = new javax.swing.JCheckBox();
        jButton4 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        chatPhotographer = new javax.swing.JComboBox();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("PHOTOGRAPH MENU");

        jPanel1.setBackground(new java.awt.Color(200, 200, 200));

        jPanel2.setBackground(new java.awt.Color(225, 225, 225));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jCheckBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox2ActionPerformed(evt);
            }
        });

        jPanel3.setBackground(new java.awt.Color(225, 225, 225));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jCheckBox4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox4ActionPerformed(evt);
            }
        });

        jPanel4.setBackground(new java.awt.Color(225, 225, 225));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jCheckBox3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox3ActionPerformed(evt);
            }
        });

        jPanel5.setBackground(new java.awt.Color(225, 225, 225));

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jCheckBox5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox5ActionPerformed(evt);
            }
        });

        jPanel7.setBackground(new java.awt.Color(225, 225, 225));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jCheckBox6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox6ActionPerformed(evt);
            }
        });

        jPanel6.setBackground(new java.awt.Color(225, 225, 225));

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jCheckBox7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox7ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jCheckBox2))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(jCheckBox5))
                                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(jCheckBox6)))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(jCheckBox7))
                                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(jCheckBox4)))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(jCheckBox3))
                                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap(24, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jCheckBox2)
                            .addComponent(jCheckBox4)
                            .addComponent(jCheckBox3)))
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCheckBox6))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCheckBox5)
                            .addComponent(jCheckBox7))))
                .addContainerGap(35, Short.MAX_VALUE))
        );

        jButton4.setText("My profile");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton3.setText("Upload");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel2.setText("User X");

        jButton2.setText("Edit");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton1.setText("logout");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel1.setText("Hello,");

        jLabel3.setText("My Photos");

        chatPhotographer.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "User 1", "User 2", "User 3", "User 4" }));

        jButton5.setText("Delete");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("Slide Show");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jLabel4.setForeground(new java.awt.Color(255, 0, 0));
        jLabel4.setText("Select a photo please");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 306, Short.MAX_VALUE)
                            .addComponent(jLabel1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jLabel2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jButton1)
                            .addGap(33, 33, 33))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButton3)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jButton5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButton4, javax.swing.GroupLayout.Alignment.LEADING))
                                .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton6))
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel3)
                                    .addContainerGap())
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addGap(9, 9, 9)))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(chatPhotographer, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton2, jButton3, jButton4, jButton5, jButton6});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel1))
                .addGap(37, 37, 37)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addGap(18, 18, 18)
                        .addComponent(jButton3)
                        .addGap(18, 18, 18)
                        .addComponent(jButton4)
                        .addGap(18, 18, 18)
                        .addComponent(jButton5)
                        .addGap(18, 18, 18)
                        .addComponent(jButton6)))
                .addGap(21, 21, 21)
                .addComponent(jLabel4)
                .addGap(7, 7, 7)
                .addComponent(chatPhotographer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>                        

   public void showPhotos(){
        
                   jPanel2.removeAll();
                   jPanel3.removeAll(); 
                   jPanel4.removeAll(); 
                   jPanel5.removeAll(); 
                   jPanel6.removeAll(); 
                   jPanel7.removeAll(); 
               
                    log.info("Show photos");
                    Object[] emailLogin = new String[1];
                    emailLogin[0] = login.getLogin();
                    
                    DBManager manager = DBManagerClass.GetInstance();              
                    
                    DBActionClass DBact = new DBActionClass("Q.photo3",emailLogin);
                    
                    DBActionResult DBres = manager.execute(DBact);
                    
                    List L = DBres.getResult();
                     log.info("Resultado obtenido");
                  
                    ToolsClass Tools = new ToolsClass(log);
                    int numero = 0;
                    
                    String name = "";
                    String path = "";
                     
                    PlanarImage image;
                    DisplayJAI dj;
                    JScrollPane newImagePane;
      
                    Iterator<Object> iterator = L.iterator();
                    
                    String thumbnailPath = Prop.getProperty("StoreThumbnail/path"); 
                    log.info("creando thumbnails en:"+thumbnailPath);
                    File photo = null;
                    while (iterator.hasNext()) {
                        log.info("entra en el while");
                        numero++;
             
        
                    switch(numero) {
                        
                            case 1: 

                                   PhotoSelected2 = (PhotoClass) iterator.next();
                                   num_photo=2;
                                   path = Prop.getProperty("GetPhoto/path")+ PhotoSelected2.getPath();
                                    log.info("Obteniendo foto" + path);
                                   photo = new File(path);
                                   name = photo.getName();
                        
                                    try {
                                        
                                        log.info("Thumbnail creada " + thumbnailPath + name);
                                        Tools.createThumbnail(path, thumbnailPath+name, 100, 100);
                                        
                                    } catch (Exception ex) {
                                        Logger.getLogger(ListenerClass.class.getName()).log(Level.SEVERE, null, ex);
                                        log.info("Error al crear la thumbnail");
                                    }
  
                                    image = JAI.create("fileload", thumbnailPath + name);
                                    dj = new DisplayJAI(image);
                                    newImagePane = new JScrollPane(dj);
                                    jPanel2.setPreferredSize(new Dimension(100,100));
                                    jPanel2.setLayout(new BoxLayout(jPanel2,BoxLayout.PAGE_AXIS));
                                    jPanel2.add(newImagePane);
                                    Panel2Activated=true;
                                    setVisible(true);


                            break;
                               
                            case 2: 

                                    num_photo=3;
                                   PhotoSelected4 = (PhotoClass) iterator.next();
                                   path = Prop.getProperty("GetPhoto/path")+ PhotoSelected4.getPath();
                                   photo = new File(path);
                                   name = photo.getName();
                        
                                    try {
                                        
                                        log.info("Thumbnail creada " + thumbnailPath + name);
                                        Tools.createThumbnail(path, thumbnailPath+name, 100, 100);
                                        
                                    } catch (Exception ex) {
                                        Logger.getLogger(ListenerClass.class.getName()).log(Level.SEVERE, null, ex);
                                        log.info("Error al crear la thumbnail");
                                    }
                                
                                    image = JAI.create("fileload", thumbnailPath + name);
                                    dj = new DisplayJAI(image);
                                    newImagePane = new JScrollPane(dj);
                                    jPanel4.setPreferredSize(new Dimension(100,100));
                                    jPanel4.setLayout(new BoxLayout(jPanel4,BoxLayout.PAGE_AXIS));
                                    jPanel4.add(newImagePane);
                                    Panel4Activated=true;
                                    setVisible(true);


                            break;
                                
                            case 3: 

                                num_photo=4;
                               PhotoSelected3 = (PhotoClass) iterator.next();
                               path = Prop.getProperty("GetPhoto/path")+ PhotoSelected3.getPath();
                               photo = new File(path);
                               name = photo.getName();
                        
                                    try {
                                        
                                        log.info("Thumbnail creada " + thumbnailPath + name);
                                        Tools.createThumbnail(path, thumbnailPath+name, 100, 100);
                                        
                                    } catch (Exception ex) {
                                        Logger.getLogger(ListenerClass.class.getName()).log(Level.SEVERE, null, ex);
                                        log.info("Error al crear la thumbnail");
                                    }
                                
                                image = JAI.create("fileload", thumbnailPath + name);
                                dj = new DisplayJAI(image);
                                newImagePane = new JScrollPane(dj);
                                jPanel3.setPreferredSize(new Dimension(100,100));
                                jPanel3.setLayout(new BoxLayout(jPanel3,BoxLayout.PAGE_AXIS));
                                jPanel3.add(newImagePane);
                                Panel3Activated=true;
                                setVisible(true);


                            break;
                                
                            case 5: 
                                   num_photo=5;
                               PhotoSelected5 = (PhotoClass) iterator.next();
                               path = Prop.getProperty("GetPhoto/path")+ PhotoSelected5.getPath();
                               photo = new File(path);
                               name = photo.getName();
                        
                                    try {
                                        
                                        log.info("Thumbnail creada " + thumbnailPath + name);
                                        Tools.createThumbnail(path, thumbnailPath+name, 100, 100);
                                        
                                    } catch (Exception ex) {
                                        Logger.getLogger(ListenerClass.class.getName()).log(Level.SEVERE, null, ex);
                                        log.info("Error al crear la thumbnail");
                                    }
                                
                                    image = JAI.create("fileload", thumbnailPath + name);
                                dj = new DisplayJAI(image);
                                newImagePane = new JScrollPane(dj);
                                jPanel5.setPreferredSize(new Dimension(100,100));
                                jPanel5.setLayout(new BoxLayout(jPanel5,BoxLayout.PAGE_AXIS));
                                jPanel5.add(newImagePane);
                                Panel5Activated=true;
                                setVisible(true);


                            break;
                            
                            case 6: 
                                num_photo=6;
                                PhotoSelected7 = (PhotoClass) iterator.next();
                                   path = Prop.getProperty("GetPhoto/path")+ PhotoSelected7.getPath();
                                   photo = new File(path);
                                   name = photo.getName();
                        
                                    try {
                                        
                                        log.info("Thumbnail creada " + thumbnailPath + name);
                                        Tools.createThumbnail(path, thumbnailPath+name, 100, 100);
                                        
                                    } catch (Exception ex) {
                                        Logger.getLogger(ListenerClass.class.getName()).log(Level.SEVERE, null, ex);
                                        log.info("Error al crear la thumbnail");
                                    }
                                
                                    image = JAI.create("fileload", thumbnailPath + name);
                                dj = new DisplayJAI(image);
                                newImagePane = new JScrollPane(dj);
                                jPanel7.setPreferredSize(new Dimension(100,100));
                                jPanel7.setLayout(new BoxLayout(jPanel7,BoxLayout.PAGE_AXIS));
                                jPanel7.add(newImagePane);
                                Panel7Activated=true;
                                setVisible(true);


                            break;
                            
                            case 7: 

                                PhotoSelected6 = (PhotoClass) iterator.next();
                                   path = Prop.getProperty("GetPhoto/path")+ PhotoSelected6.getPath();
                                   photo = new File(path);
                                   name = photo.getName();
                        
                                    try {
                                        
                                        log.info("Thumbnail creada " + thumbnailPath + name);
                                        Tools.createThumbnail(path, thumbnailPath+name, 100, 100);
                                        
                                    } catch (Exception ex) {
                                        Logger.getLogger(ListenerClass.class.getName()).log(Level.SEVERE, null, ex);
                                        log.info("Error al crear la thumbnail");
                                    }
                                
                                    image = JAI.create("fileload", thumbnailPath + name);
                                dj = new DisplayJAI(image);
                                newImagePane = new JScrollPane(dj);
                                jPanel6.setPreferredSize(new Dimension(100,100));
                                jPanel6.setLayout(new BoxLayout(jPanel6,BoxLayout.PAGE_AXIS));
                                jPanel6.add(newImagePane);
                                Panel6Activated=true;
                                setVisible(true);


                            break;
                  
                    } 
     
          }
 
        
 }


public static void openURL(String url) {
        String osName = System.getProperty("os.name");
        try {
            if (osName.startsWith("Windows")) {
                Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
            } else if (osName.startsWith("Mac OS X")) {
                // Runtime.getRuntime().exec("open -a safari " + url);
                // Runtime.getRuntime().exec("open " + url + "/index.html");
                Runtime.getRuntime().exec("open " + url);
            } else {
                System.out.println("Please open a browser and go to "+ url);
            }
        } catch (IOException e) {
            System.out.println("Failed to start a browser to open the url " + url);
            e.printStackTrace();
        }
    }


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
// TODO add your handling code here:
    login log=new login();
    log.setVisible(true);
    this.setVisible(false);
    
}                                        

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
// TODO add your handling code here:
    profile prof = new profile();
    prof.setVisible(true);
}                                        

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
// TODO add your handling code here:
    int num_photo1=0;
    jLabel4.setVisible(false);
    if(jCheckBox2.isSelected()==true || jCheckBox2.isSelected()==true || jCheckBox4.isSelected()==true
            || jCheckBox5.isSelected()==true || jCheckBox6.isSelected()==true || jCheckBox7.isSelected()==true){
        
        String path = null;
        if(jCheckBox2.isSelected() && Panel2Activated == true){
        num_photo1=1;
        path = Prop.getProperty("GetPhoto/path")+ PhotoSelected2.getPath();  
        }
        if(jCheckBox3.isSelected() && Panel3Activated == true){
            num_photo1=3;
            path = Prop.getProperty("GetPhoto/path")+ PhotoSelected3.getPath();
        }
        if(jCheckBox4.isSelected() && Panel4Activated == true){
            num_photo1=2;
             path = Prop.getProperty("GetPhoto/path")+ PhotoSelected4.getPath();
        }
        if(jCheckBox5.isSelected() && Panel5Activated == true){
            num_photo1=4;
            path = Prop.getProperty("GetPhoto/path")+ PhotoSelected5.getPath();
        }
        if(jCheckBox6.isSelected() && Panel6Activated == true){
            num_photo1=5;
            path = Prop.getProperty("GetPhoto/path")+ PhotoSelected6.getPath();
        }
        if(jCheckBox7.isSelected() && Panel7Activated == true){
            num_photo1=6;
              path = Prop.getProperty("GetPhoto/path")+ PhotoSelected7.getPath();
        
       
        }
        editPhoto ed = new editPhoto(path, num_photo1);
        ed.setVisible(true);
    }
    else
        jLabel4.setVisible(true);    

    
    
      
    
}                                        

private void jCheckBox3ActionPerformed(java.awt.event.ActionEvent evt) {                                           
// TODO add your handling code here:
        jCheckBox2.setSelected(false);
        jCheckBox4.setSelected(false);
        jCheckBox5.setSelected(false);
        jCheckBox6.setSelected(false);
        jCheckBox7.setSelected(false);
}                                          

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
// TODO add your handling code here:
    upload up = new upload(num_photo);
    up.setVisible(true);
    
       
}                                        

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                         
// TODO add your handling code here:
    openURL("localhost:8080/");
}                                        

    private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        jCheckBox3.setSelected(false);
        jCheckBox4.setSelected(false);
        jCheckBox5.setSelected(false);
        jCheckBox6.setSelected(false);
        jCheckBox7.setSelected(false);
    }                                          

    private void jCheckBox4ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        jCheckBox3.setSelected(false);
        jCheckBox2.setSelected(false);
        jCheckBox5.setSelected(false);
        jCheckBox6.setSelected(false);
        jCheckBox7.setSelected(false);
    }                                          

    private void jCheckBox5ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        jCheckBox3.setSelected(false);
        jCheckBox4.setSelected(false);
        jCheckBox2.setSelected(false);
        jCheckBox6.setSelected(false);
        jCheckBox7.setSelected(false);
    }                                          

    private void jCheckBox6ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        jCheckBox3.setSelected(false);
        jCheckBox4.setSelected(false);
        jCheckBox5.setSelected(false);
        jCheckBox2.setSelected(false);
        jCheckBox7.setSelected(false);
    }                                          

    private void jCheckBox7ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        jCheckBox3.setSelected(false);
        jCheckBox4.setSelected(false);
        jCheckBox5.setSelected(false);
        jCheckBox6.setSelected(false);
        jCheckBox2.setSelected(false);
    }                                          

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       
        jLabel4.setVisible(false);
    if(jCheckBox2.isSelected()==true || jCheckBox2.isSelected()==true || jCheckBox4.isSelected()==true
            || jCheckBox5.isSelected()==true || jCheckBox6.isSelected()==true || jCheckBox7.isSelected()==true){
        
    }
    else
        jLabel4.setVisible(true);
    }                                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(photographersMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(photographersMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(photographersMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(photographersMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new photographersMenu().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    public javax.swing.JComboBox chatPhotographer;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JCheckBox jCheckBox3;
    private javax.swing.JCheckBox jCheckBox4;
    private javax.swing.JCheckBox jCheckBox5;
    private javax.swing.JCheckBox jCheckBox6;
    private javax.swing.JCheckBox jCheckBox7;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    // End of variables declaration                   
}
